#
# Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
#
# GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
# Author: Shawn.Tan
# Date: 2025.10.28
#
# History: Initial Version 2025.10.28
#
#
from gpgpu.EnvGPGPU import EnvGPGPU
from gpgpu.GenThreadGPGPU import GenThreadGPGPU
from base.Sequence import Sequence
from base.SequenceLibrary import SequenceLibrary


class MainSequence(Sequence):
    def generate(self, **kargs):
        if self.getGlobalState("AppRegisterWidth") == 32:
            seq_library = MySequenceLibrary32(self.genThread)
        else:
            seq_library = MySequenceLibrary(self.genThread)

        # 4 iterations of selecting a sequence randomly from the list
        for _ in range(4):
            current_sequence = seq_library.chooseOne()
            current_sequence.run()

        # In a random order, select and run with each sequence in the list
        for current_sequence in seq_library.getPermutated():
            current_sequence.run()


class MySequenceLibrary(SequenceLibrary):
    def createSequenceList(self):
        self.seqList = [
            (
                "Bunch_of_ALU_Int",
                "DV.gpgpu.sequences.BasicSequences",
                "Your Description",
                20,
            ),
            (
                "Bunch_of_LDST",
                "DV.gpgpu.sequences.BasicSequences",
                "Your Description",
                20,
            ),
        ]


class MySequenceLibrary32(SequenceLibrary):
    def createSequenceList(self):
        self.seqList = [
            (
                "Bunch_of_ALU_Int32",
                "DV.gpgpu.sequences.BasicSequences",
                "Your Description",
                20,
            ),
            (
                "Bunch_of_LDST32",
                "DV.gpgpu.sequences.BasicSequences",
                "Your Description",
                20,
            ),
        ]


#  Points to the MainSequence defined in this file
MainSequenceClass = MainSequence

#  Using GenThreadGPGPU by default, can be overriden with extended classes
GenThreadClass = GenThreadGPGPU

#  Using EnvGPGPU by default, can be overriden with extended classes
EnvClass = EnvGPGPU
